home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr14
/
dndprogs.zip
/
DICE
< prev
next >
Wrap
Text File
|
1993-04-01
|
4KB
|
126 lines
Path: pdxgate!ogicse!mintaka!think.com!snorkelwacker.mit.edu!stanford.edu!agate!darkstar!ucscb.UCSC.EDU!iago
From: iago@ucscb.UCSC.EDU (tsource)
Newsgroups: rec.games.frp
Subject: dice curve plote 1.0
Message-ID: <14123@darkstar.ucsc.edu>
Date: 4 Apr 91 10:46:25 GMT
Sender: usenet@darkstar.ucsc.edu
Organization: University of California, Santa Cruz; Open Access Computing
Lines: 113
Posted: Thu Apr 4 02:46:25 1991
Warning: Poster tried to forge this article as tsource@ucscb.ucsc.edu (tsource)
Here is something someone might find useful
FAST NOTE: the code is not the best of style (it works
though) since I wrote in the wee morning hours after a
party
------------------------- CUT HERE ---------------------------
Ever wanted to get data on the curve of a specfic fundimental die roll
i.e. XdY with no modifers. Well maybe dice plot 1.0 (actually called dice
when called) can shed some light on the matter. It will ask what your
fundtimental die is (i.e. XdY) and how many samples (i.e. how times to
roll the fundtimental die). Also if you want to put it in a file
if so then it will ask for the file name. For example
the following input will produce this output to the screen
Input:
How many times rolled and how many dice (xdy): 3d6
How many samples: 20000
Do you want a outfile(y or n): n
Output:
This is the result of 20000 rolls of 3d6
# % tot % lower % higher number graph
3 0.495 0.000 99.505 99 *
4 1.265 0.495 98.240 253 **
5 2.995 1.760 95.245 599 ***
6 4.435 4.755 90.810 887 *****
7 7.010 9.190 83.800 1402 ********
8 9.750 16.200 74.050 1950 **********
9 11.385 25.950 62.665 2277 ************
10 12.295 37.335 50.370 2459 *************
11 12.890 49.630 37.480 2578 *************
12 11.490 62.520 25.990 2298 ************
13 10.070 74.010 15.920 2014 ***********
14 6.710 84.080 9.210 1342 *******
15 4.690 90.790 4.520 938 *****
16 2.715 95.480 1.805 543 ***
17 1.375 98.195 0.430 275 **
18 0.430 99.570 -0.000 86 *
Other then that I should warn you that for 1dy it often gives bad high and low
%'s. Also sometimes you will get -0% the problem is it truncates but the
truncating so far has no noticable effect except for this wierd percentage.
Other then that if you have bug reports, complaiments, and or flames send them
to aryeh@cash.ucsc.edu or bfwong@ocf.berkeley.edu
Except for that here is a list of what I want to add to further versions.
-- complex dice systems
-- fix 1dy bug
-- add calced stadard devations
------------------------ CUT HERE ------------------------------------
#include <stdio.h>
main()
{
long i,j,k,*res;
double per,minper,maxper,strange_per;
int x,y;
long MAXROLLS;
char c[80],filename[80];
FILE *fp;
printf("Numer of times rolled and # of dice (xdy) for each:");
scanf("%dd%d",&y,&x);
printf("How many samples should I have:");
scanf("%d",&MAXROLLS);
printf("Do you want a output file(y or n):");
scanf("%s",c);
if(strcmp(c,"y")==0){
printf("What outfile do you want:");
scanf("%s",filename);
fp=fopen(filename,"w");
}
else fp=stdout;
res=(int *) malloc(((x*y)+1)*sizeof(long));
for(j=y;j<x+y;j++) res[j]=0;
for(j=0;j<=MAXROLLS-1;j++){
i=0;
for(k=0;k<y;k++) i+=(int) (random()%x)+1;
res[i]++;
}
fprintf(fp,"This is the result of %d rolls of %dd%d\n",MAXROLLS,y,x);
fprintf(fp,"#\t%% tot\t%% lower\t%% higher\tnumber\tgraph\n");
/* we need to keep track of this to have maxper, minper and per add up
to 100 and be 0 at the extremes */
strange_per=res[(x*y)+1];
strange_per/=MAXROLLS;
strange_per*=100;
maxper=100+strange_per;
/* since the actually workings of max and min will zero them to their
defaults */
for(j=y;j<(x*y)+1;j++){
per=res[j];
per/=MAXROLLS;
per*=100;
/* I have no idea at all why it refuses to allow me to use
1 statement ;-((( */
maxper-=per;
minper=100-(maxper+per);
fprintf(fp,"%d\t%5.3f\t%5.3f\t%5.3f\t\t%d\t",j,per,minper,
maxper,res[j]);
for(k=0;k<(int) per+1;k++) putc('*',fp);
putc('\n',fp);
}
}
------------------------------ CUT HERE --------------------------
--
[=] [=-=] [=]
| |=-=-| c |-=-=| |
_|_|____|_^_|____|_|_
(iago@ucscb.ucsc.edu)